﻿Imports System.Collections.Generic
Imports System.Data
Imports CondorTravel.BC
Imports CondorTravel.BE
Imports CondorTravelUTIL.DL


Public Class BuscarSolicitudServicio
    Inherits PaginaBase

    Public s As New PaginaBase

    Public scodigo As String = String.Empty
    Public sProveedores As String
    Public sDescServicio As String


    Dim itemgridview As GridViewRow
    Dim casilla As System.Web.UI.WebControls.CheckBox

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load


    End Sub

    Protected Sub btnConsultar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnConsultar1.Click
        ListarSolicitudesServ()
    End Sub


    Private Sub ListarSolicitudesServ()

        Dim objSolicitudServBE As New SolicitudServicioBE
        Dim objSolicitudServBC As New SolicitudServicioBC
        Dim bExito As Boolean = False
        Dim sMensaje As String = String.Empty
        Dim objUtil As New Funciones

        objSolicitudServBE.CodSolicitud = Val(objUtil.ReemplazarTexto(txtCodSolicitud.Text.Trim))
        objSolicitudServBE.NombreServicio = txtNombreServ.Text.Trim

        dgProveedor.DataSource = objSolicitudServBC.ListarSolicitudServicio_Busqueda(objSolicitudServBE, bExito, sMensaje)
        dgProveedor.DataBind()

    End Sub

    Protected Sub btnSeleccionar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSeleccionar.Click

        Dim dt As New DataTable
        Dim objAdministrarServicios As New AdministrarServicios


        Dim sRazonSocial As String = String.Empty
        Dim sRuc As String = String.Empty

        Dim iContador As Integer
        For Each Me.itemgridview In dgProveedor.Rows
            casilla = itemgridview.FindControl("chkSeleccionar")
            If casilla.Checked = True Then
                iContador = iContador + 1
            End If
        Next

        If iContador > 1 Then
            Alerta("Solo se permite seleccionar un registro.", False, String.Empty)
            Exit Sub
        End If



        For Each Me.itemgridview In dgProveedor.Rows
            casilla = itemgridview.FindControl("chkSeleccionar")

            If casilla.Checked = True Then
                scodigo = CType(itemgridview.FindControl("lblcodigo"), Label).Text
                sProveedores = CType(itemgridview.FindControl("lblProveedores"), Label).Text
                sDescServicio = CType(itemgridview.FindControl("lblDescripcionServicio"), Label).Text

            End If

        Next

        If scodigo = String.Empty Then
            Exit Sub
        End If

        'Response.Write("<script language=Javascript>window.opener.location.reload();</script>")
        Response.Write("<script language=Javascript>window.close();</script>")
        Session("BSSCodigoSolicitud") = scodigo
        Session("BSSNombreSolicitud") = sDescServicio
        Session("BSSProveedorSolicitud") = sProveedores
       

    End Sub


    Protected Sub btnSalir_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSalir.Click 
        Response.Write("<script language=Javascript>window.close();</script>")
    End Sub


End Class